<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,  user-scalable=no">
    <title>全膝关节功能</title>
    <style>
        #table_total_edit {
            font-size: 14px;
        }

        #table_total_edit input {
            border: 0;
        }

        #table_total td, #table_total_edit td {
            width: 50%;
            text-align: center;
            background-color: #fff;
        }

        #table-data dl, #table-data dt, #table-data dd {
            width: 100% !important;
            text-align: left;
        }

        #table-data dd {
            margin-left: 1vw;
        }

        #table-data dd {
            margin-top: 1vw;
        }

        #table-data dt {
            margin-top: 2vw;
        }

        #sf-36-questions ul {
            width: 100% !important;
        }

        #sf-36-questions ul li {
            list-style-type: none !important;
            display: inline-block !important;
            text-align: left !important;
        }

        #sf-36-questions ul li:nth-child(n + 2) {
            margin-left: 3vw;
        }

        #table_total_edit input {
            border: 0;
        }
        
        #table_total input {
        	border: none !important;
        	background-color: #fff;
        	text-align: center;
        }

        #knee-assessment hr {
            width: 100%;
            border: 1px solid #eee;
        }

        #knee-assessment ul {
            list-style: none;
            padding: 0px;
            margin: 0px;
        }

        #knee-assessment ul li {
            display: inline-block;
            list-style: none;
            min-width: 100px;
        }

        #gauge_form .group-div {
            border-bottom: 1px dashed #d0d0d0;
            margin: 20px 0 15px !important;
            padding-bottom: 1vw;
        }

        #gauge_form .col-sm-3, #gauge_form .col-sm-9{
            padding-left: 0;
        }

        #gauge_form .input-score {
            /*background-color: white;*/
        }
        
        #gauge_form input::-webkit-outer-spin-button,input::-webkit-inner-spin-button {
	        -webkit-appearance: none !important;
	        margin: 0;
        }
        
        #gauge_form input[type="number"] {
        	-moz-appearance:textfield;
        }

    </style>

</head>

<body>
<form id="gauge_form">
    <div id="knee-assessment">
        <div class="" style="border-bottom: 1px solid #d0d0d0;">
            <label style="font-size: 16px;font-weight: bold;">评定内容</label>
        </div>

        <div class="hide" style="margin-top: 20px;">
            <table border="0" cellspacing="0" cellpadding="0" style="margin-left: 5vw;">
                <tr>
                    <td align="left" style="width: 8vw;vertical-align: middle;"><label style="font-size: 13px">陪同者</label></td>
                    <td align="left" style="vertical-align: middle;"><input id="text_companion" name="text_companion" type="text" class="question-item form-control" style="width: 12vw;"/>
                    </td>
                </tr>
            </table>
        </div>

        <div id="group-1" class="row group-div">
            <div class="col-sm-12" style="padding-left: 0;">
                <label style="font-size: 14px;font-weight: bold;">功能评分</label>
            </div>
            <table class="col-sm-12">
                <tr>
                    <td class="col-sm-3">
                        <label style="font-size: 13px;margin-left: 5vw;">行走*</label>
                    </td>
                    <td class="col-sm-9">
                        <input class="question-radio" name="1-1"  value="50" type="radio">不受限
                        <input class="question-radio" name="1-1"  value="40" type="radio" style="margin-left: 2vw;">大于2km
                        <input class="question-radio" name="1-1"  value="30" type="radio" style="margin-left: 2vw;">1-2km
                        <input class="question-radio" name="1-1"  value="20" type="radio" style="margin-left: 2vw;">小于1km
                        <input class="question-radio" name="1-1"  value="10" type="radio" style="margin-left: 2vw;">仅限于屋内
                        <input class="question-radio" name="1-1"  value="0" type="radio" style="margin-left: 2vw;">不能行走
                    </td>
                </tr>
            </table>
        </div>

        <div id="group-2" class="row group-div" style="margin-bottom: 1vw;">
            <table class="col-sm-12">
                <tr>
                    <td class="col-sm-3">
                        <label style="font-size: 13px;margin-left: 5vw;">上下楼梯*</label>
                    </td>
                    <td class="col-sm-9">
                        <span style="min-width: 15vw; display: inline-block"><input class="question-radio" name="2-1" value="50" type="radio">正常上下楼梯</span>
                        <span style="min-width: 15vw; display: inline-block"><input class="question-radio" name="2-1" value="40" type="radio">正常上楼梯，扶栏杆下楼</span>
                    </td>
                </tr>
                <tr>
                    <td class="col-sm-3">
                    </td>
                    <td class="col-sm-9">
                        <span style="min-width: 15vw; display: inline-block"><input class="question-radio" name="2-1" value="30" type="radio">上下楼时均需扶栏杆</span>
                        <span style="min-width: 15vw; display: inline-block"><input class="question-radio" name="2-1" value="15" type="radio">上楼需扶栏杆，不能下楼</span>
                        <span style="min-width: 15vw; display: inline-block"><input class="question-radio" name="2-1" value="0" type="radio">不能上下楼</span>
                    </td>
                </tr>
            </table>

        </div>

        <div id="group-2-1" class="row group-div" style="margin-bottom: 1vw;">
            <table class="col-sm-12">
                <tr>
                    <td class="col-sm-3">
                        <label style="font-size: 13px;margin-left: 5vw;">减分项（可选）</label>
                    </td>
                    <td class="col-sm-9">
                        <input class="question-radio" name="2-1-1" value="0" type="radio">无
                        <input class="question-radio" name="2-1-1" value="-5" type="radio" style="margin-left: 1vw;">单手杖
                        <input class="question-radio" name="2-1-1" value="-10" type="radio" style="margin-left: 1vw;">双手杖
                        <input class="question-radio" name="2-1-1" value="-20" type="radio" style="margin-left: 1vw;">抚拐或助行器
                    </td>
                </tr>
            </table>
        </div>

        <div id="group-3" class="row group-div" style="margin-bottom: 1vw;">
            <table class="col-sm-12">
                <tr>
                    <td class="col-sm-3">
                        <label style="font-size: 13px;margin-left: 5vw;">得分</label>
                    </td>
                    <td class="col-sm-9">
                        <input readonly="readonly" disabled="disabled"  class="question-item input-score form-control" name="3-1" value="" type="text" style="width: 200px;" />
                    </td>
                </tr>
            </table>
        </div>

        <div id="group-4" class="row group-div">
            <div class="col-sm-12" style="padding-left: 0;">
                <label style="font-size: 14px;font-weight: bold;">临床评分</label>
            </div>

            <table class="col-sm-12">
                <tr>
                    <td class="col-sm-3">
                        <label style="font-size: 13px;margin-left: 5vw;">平地行走（疼痛）*</label>
                    </td>
                    <td class="col-sm-9">
                        <input class="question-radio" name="4-1" value="35" type="radio">无痛
                        <input class="question-radio" name="4-1" value="30" type="radio" style="margin-left: 5vw;">轻度或偶尔疼痛
                        <input class="question-radio" name="4-1" value="15" type="radio" style="margin-left: 5vw;">中度疼痛
                        <input class="question-radio" name="4-1" value="0" type="radio" style="margin-left: 5vw;">重度疼痛
                    </td>
                </tr>
            </table>

        </div>

        <div id="group-5" class="row group-div">
            <table class="col-sm-12">
                <tr>
                    <td class="col-sm-3">
                        <label style="font-size: 13px;margin-left: 5vw;">爬楼梯（疼痛）*</label>
                    </td>
                    <td class="col-sm-9">
                        <input class="question-radio" name="5-1" value="15" type="radio">无痛
                        <input class="question-radio" name="5-1" value="10" type="radio" style="margin-left: 5vw;">轻度或偶尔疼痛
                        <input class="question-radio" name="5-1" value="5" type="radio" style="margin-left: 5vw;">中度疼痛
                        <input class="question-radio" name="5-1" value="0" type="radio" style="margin-left: 5vw;">重度疼痛
                    </td>
                </tr>
            </table>
        </div>

        <div id="group-6" class="row group-div">
            <table class="col-sm-12">
                <tr>
                    <td class="col-sm-3">
                        <label style="font-size: 13px;margin-left: 5vw; padding-top: 20px;">活动度*</label>
                    </td>
                    <td class="col-sm-9">
                        <input type="number" name="6-1" value="0" class="question-item form-control" id="slider-result" readonly="readonly" style="width: 50px; display: inline-block;"><span>度</span>
                        <input type="range" name="6-2" value="0" class="question-item" max="125" min="0" step="5" onchange="$('#slider-result').val($(this).val());">
                        <div style="font-size: 12px;">提示：活动度范围（0-125度）</div>
                    </td>
                </tr>
            </table>
        </div>

        <div id="group-7" class="row group-div">
            <table class="col-sm-12">
                <tr>
                    <td class="col-sm-3">
                        <label style="font-size: 13px;margin-left: 5vw;">前后方向稳定性（胫骨对股骨在任何方向上的位移）*</label>
                    </td>
                    <td class="col-sm-9">
                        <input class="question-radio" name="7-1" value="10" type="radio">小于5mm
                        <input class="question-radio" name="7-1" value="5" type="radio" style="margin-left: 2vw;">5-10mm
                        <input class="question-radio" name="7-1" value="0" type="radio" style="margin-left: 2vw;">大于10mm
                    </td>
                </tr>
            </table>
        </div>

        <div id="group-8" class="row group-div">
            <table class="col-sm-12">
                <tr>
                    <td class="col-sm-3">
                        <label style="font-size: 13px;margin-left: 5vw;">内外方向稳定性（胫骨对股骨在任何方向上的位移）</label>
                    </td>
                    <td class="col-sm-9">
                        <input class="question-radio" name="8-1" value="15" type="radio">小于5mm
                        <input class="question-radio" name="8-1" value="10" type="radio" style="margin-left: 2vw;">6-9mm
                        <input class="question-radio" name="8-1" value="5" type="radio" style="margin-left: 2vw;">10mm-14mm
                        <input class="question-radio" name="8-1" value="0" type="radio" style="margin-left: 2vw;">大于等于15mm
                    </td>
                </tr>
            </table>
        </div>

        <div id="group-9" class="row group-div" style="margin-bottom: 1vw;">
            <table class="col-sm-12">
                <tr>
                    <td class="col-sm-3">
                        <label style="font-size: 13px;margin-left: 5vw;">得分</label>
                    </td>
                    <td class="col-sm-9">
                        <input readonly="readonly" disabled="disabled" class="question-item input-score form-control" name="9-1" value="" type="text" style="width: 200px;" />
                    </td>
                </tr>
            </table>
        </div>

        <div id="group-10" class="row group-div">
            <table class="col-sm-12">
                <tr>
                    <td class="col-sm-3">
                        <label style="font-size: 13px;margin-left: 5vw;">屈曲畸形</label>
                    </td>
                    <td class="col-sm-9">
                        <ul>
                            <li><input class="question-radio" name="10-1" value="0" type="radio">小于5度</li>
                            <li><input class="question-radio" name="10-1" value="-2" type="radio" style="margin-left: 2vw;">5-10度</li>
                            <li><input class="question-radio" name="10-1" value="-5" type="radio" style="margin-left: 2vw;">11-15度</li>
                            <li><input class="question-radio" name="10-1" value="-10" type="radio" style="margin-left: 2vw;">16-20度</li>
                            <li><input class="question-radio" name="10-1" value="-15" type="radio" style="margin-left: 2vw;">大于20度</li>
                        </ul>
                    </td>
                </tr>
            </table>

        </div>

        <div id="group-11" class="row group-div">

            <table class="col-sm-12">
                <tr>
                    <td class="col-sm-3">
                        <label style="font-size: 13px;margin-left: 5vw;">过伸</label>
                    </td>
                    <td class="col-sm-9">
                        <ul>
                            <li><input class="question-radio" name="11-1" value="0" type="radio">无</li>
                            <li><input class="question-radio" name="11-1" value="-5" type="radio" style="margin-left: 2vw;">小于10度</li>
                            <li><input class="question-radio" name="11-1" value="-10" type="radio" style="margin-left: 2vw;">10-20度</li>
                            <li><input class="question-radio" name="11-1" value="-15" type="radio" style="margin-left: 2vw;">大于20度</li>
                        </ul>
                    </td>
                </tr>
            </table>

        </div>

        <div id="group-12" class="row group-div" style="border-bottom: none;">
            <table class="col-sm-12">
                <tr>
                    <td class="col-sm-3">
                        <label style="font-size: 13px;margin-left: 5vw;">力线</label>
                    </td>
                    <td class="col-sm-9">
                        <ul>
                            <li><input class="question-radio" name="12-1" value="0" type="radio">内翻</li>
                            <li><input class="question-radio" name="12-1" value="1" type="radio">外翻</li>
                            <li><input class="question-radio" name="12-1" value="2" type="radio">无内外翻</li>
                            <li><input class="question-item input-score form-control" name="12-2" value="" type="number" placeholder="内/外翻需要填写(范围0-200度)" max="200" style="width: 200px; display: inline-block;"/>度</li>
                        </ul>
                    </td>
                </tr>
            </table>

        </div>
        
        <div id="group-13" class="row group-div">
            <table class="col-sm-12">
                <tr>
                    <td class="col-sm-3">
                        <label style="font-size: 13px;margin-left: 5vw;">休息时疼痛</label>
                    </td>
                    <td class="col-sm-9">
                        <ul>
                            <li><input class="question-radio" name="13-1" value="-5" type="radio">轻度疼痛</li>
                            <li><input class="question-radio" name="13-1" value="-10" type="radio" style="margin-left: 2vw;">中度疼痛</li>
                            <li><input class="question-radio" name="13-1" value="-15" type="radio" style="margin-left: 2vw;">重度疼痛</li>
                        </ul>
                    </td>
                </tr>
            </table>
        </div>

        <div id="group-14" class="row group-div" style="margin-bottom: 1vw;">
            <table class="col-sm-12">
                <tr>
                    <td class="col-sm-3">
                        <label style="font-size: 13px;margin-left: 5vw;">得分</label></div>
                    </td>
                    <td class="col-sm-9">
                        <input readonly="readonly" disabled="disabled" class="question-item input-score form-control" style="width: 200px;" name="14-1" value="" type="text" />
                    </td>
                </tr>
            </table>

        </div>

        <div id="div_edit" class="" style="margin-top: 20px;border-bottom: 1px solid #d0d0d0;">
            <label style="font-size: 16px;font-weight: bold;">评定结果</label>
        </div>
         <div style="margin-top: 20px;">
            <table id="table_total" class="table table-bordered" style="margin-top: 20px;border:1px solid #e7e7e7;" border="1" cellspacing="0" cellpadding="0">
                <tr>
                    <td style="text-align: center;">临床评分总分</td>
                    <td style="text-align: center;"><span class="input-score" name="15-1" id="15-1"></span></td>
                </tr>
                 <tr>
                    <td style="text-align: center;">评分分级</td>
                    <td style="text-align: center;"><span class="input-score" name="16-1" id="16-1"></span></td>
                </tr>
            </table>
        </div>

        <div class="edit-page" style="margin-top: 20px">
            <div class="col-sm-8 col-sm-offset-4">
                <button class="btn btn-white col-sm-3" type="reset" onclick="myReset()">重置</button>
                <button class="btn btn-primary col-sm-3 col-sm-offset-1" onclick="submitGaugeResult()" type="button">提交
                </button>
            </div>
        </div>

        <div id="table-data"></div>

    </div>
</form>
</body>

<script>
    var editPage = $(".edit-page");
    var viewPage = $(".view-page");

    var totalRatio = 0;
    var totalScore = 0;

    var totalItem = 0; // 选择题总数
    var inputItemList = {}; // 存储所有的选项和分数
    var resultScore = {}; // 计算后的栏目分数
    var calItem122 = true;

    function setEditable(edit) {
        if (edit) {
            editPage.removeClass('hide');
            viewPage.addClass('hide');
        } else {
            viewPage.removeClass('hide');
            editPage.addClass('hide');
            $(".question-radio").prop('disabled', 'disabled');
            $(".question-item").prop('disabled', 'disabled');
            $("#knee-assessment input").attr('disabled', 'disabled');
        }
    }

    function setGaugeResult(result) {
        $.each(result.questions, function (idx, val) {
            var obj = $("#knee-assessment [name='" + val.key + "']");
            if (obj.prop("type") == "radio") {
                $("#knee-assessment input[type='radio'][name='" + val.key + "'][value='" + val.value + "']").prop("checked", "checked");
            } else {
                obj.val(val.value);
            }

            computeScore();
        });
    }

    function getGaugeResult() {
//    	debugger;
    	var result = {'questions':[]};
        var items = $("#knee-assessment .question-item"); // 所有输入项
        var radios = $("#knee-assessment input[type='radio']:checked"); // 所有选项项

        for (var i = 0; i < items.length; i++) {
        	if(!checkSpecifyItem(items[i])) {
                return null;
        	}
            
            var res = {};
            res.key = $(items[i]).attr("name");
            res.value = $(items[i]).val();
            result.questions.push(res);
        }

        // 检查所有的radio选择项是否已经全部选项
        var radiolist = $("#knee-assessment input[type='radio']");
        var enough = true;
        $.each(radiolist, function(idx, val){
            //debugger;
        	var name = $(val).attr("name");
        	if(!$("#knee-assessment input[name=" + name + "]").is(":checked")) {
                utils.msgError("请完成所有问题");
        		 $(val).focus();
        		 enough = false;
                 return false;
        	}
        });
        
        if(!enough) {
        	return null;
        }
        	
        for (var j = 0; j < radios.length; j++) {
            var res = {};
            res.key = $(radios[j]).attr("name");
            res.value = $("#knee-assessment input[name='" + res.key + "']:checked").val();
            result.questions.push(res);
        }

        debugAlert(result);
        return result;
    }
    
    /**
    * 每个选项的校验规则， 如果没有定义，就按通用的校验规则来
    */
    var checkItems = {
    		"text_companion":function(that){
    			// 元素名称 1 陪同者姓名， 2 力线
    	     	var companion = $("#text_companion").val();
    	     	if (!isBlank(companion) && companion.length > 10) {
                    utils.msgError("陪同者名称长度限制在10以内!");
    	     		$("#text_companion").focus();
    	     		return false;
    	     	}
    	     	return true;
    		},
    		"12-2":function(that){
    			// 检查有没有选中外翻或内翻
             	var checkedLength = $('#knee-assessment input[name="12-1"]:checked').length;
             	if (checkedLength == 0){ // 没有选中
             		// utils.msgError("请完成所有问题");
             		// return false;
             	}
             	
             	var i12a = $('#knee-assessment input[name="12-1"]:checked');
         		var choice = i12a.val();
         		if (choice == 0|| choice == 1) { // 0 外翻 1 内翻
         		   	var lx = $('#knee-assessment input[name=12-2]').val(); // 检查力线范围0-200之间
         		   	var range = getCalculableScore(lx);
         		   	if (0 > range || 200 < range) {
                        utils.msgError("力线范围限制在[0-200]之间!");
         		   		$('#knee-assessment input[name=12-2]').focus();
         		   		return false;
         		   	} else {
         		   		$('#knee-assessment input[name=12-2]').val(range);
         		   		return true;
         		   	}
         		}
         			
         		if(choice == 2){
         			$('#knee-assessment input[name=12-2]').val(""); // 将选中的值清空
         		}
             	return true;
    		},
    		"12-1":function(that){
    			var $that = $(that);
    			var checked = $('#knee-assessment input[name=12-1]:checked');
    			var chk = checked.val();
    			if(checked.val() == 2) {// 无内外翻
    				$('#knee-assessment input[name=12-2]').val(""); // 将选中的值清空
    			} else {
    				var score = $('#knee-assessment input[name=12-2]').val();
    				if (score == "") {
    					$('#knee-assessment input[name=12-2]').val("0");
    				} else if (score < 0 || score > 200) {
                        utils.msgError("力线范围限制在[0-200]之间!");
     		     		$('#knee-assessment input[name=12-2]').focus();
    					return false;
    				}
    			}
    			return true;
    		},
    		"general": function(that){
//                debugger;
    			if(typeof(that) == "undefined" || that == null || $(that).val() == "null" || $(that).val() == ""){
                    utils.msgError("请完成所有问题");
    	     		return false;
    			}
    			return true;
    		}
    };
    
    /**
    * 检查用户的输入项, 用户自定义检查方法
    */
    var checkSpecifyItem = function(that){
    	var key = $(that).attr("name");
    	var func = checkItems[key];
    	return func == undefined ? checkItems["general"](that) : func(that);
    }
    
    /**
     * 计算功能得分1-1, 2-1, 2-1-1
     */
    var computeFuncScore = function(){
        var funcItem = {'1-1':{'type':'radio', 'optional':false}, '2-1':{'type':'radio'}, '2-1-1':{'type':'radio'}};
        var funcScore = 0;

        $.each(funcItem, function(key, val){
            var type = val['type'];
            var optl = val['optional'] == undefined;

            if ('radio' == type) {
                var length = $('#knee-assessment input[name=' + key + ']:checked').length;
                if (0 == length && !optl) {
                    return;
                }
                $('#knee-assessment input[name=' + key + ']:checked').each(function(k, v){
                    var score = $(this).val();
                    funcScore += getCalculableScore(score);
                });
            }
        });

        $('#knee-assessment input[name="3-1"]').val(getDisplayScore(funcScore));
    }

    /**
     * 计算临床得分
     */
    var clinicalScore = function(){
        var funcItem = {'4-1':{'type':'radio', 'optional':false}, '5-1':{'type':'radio'}, '6-1':{'type':'number'}, '7-1':{'type':'radio'}, '8-1':{'type':'radio'}};
        var funcScore = 0;

        $.each(funcItem, function(key, val){
            var type = val['type'];
            var optl = val['optional'] == undefined;

            if ('radio' == type) {
                var length = $('#knee-assessment input[name=' + key + ']:checked').length;
                if (0 == length && !optl) {
                    return;
                }
                $('#knee-assessment input[name=' + key + ']:checked').each(function(k, v){
                    var score = $(this).val();
                    funcScore += getCalculableScore(score);
                });
            } else if('number' == type) { // 活动度 目前只有 6-1是number
                var degree = $('#knee-assessment input[name=' + key + ']').val();
                funcScore += getDegreeScore(degree, 1);
            }

        });

        $('#knee-assessment input[name="9-1"]').val(getDisplayScore(funcScore));
    }

    /**
     * 计算减分项
     * 12-1不参与计算，12-1选择'外翻'或'内翻'时，12-2才参与计算
     *
     * 减分项包括
     * 10-1 => 屈曲畸形
     * 11-1 => 过伸
     * 12-1 => 力线 (每增加5度减3分)
     * 13-1 => 休息时疼痛
     * 12-2 => 力线度数
     */
    var reduceScore = function(){
        var items = {'10-1':{'type':'radio', 'optional':false}, '11-1':{'type':'radio'}, '12-2':{'type':'number'}, '13-1':{'type':'radio'}};
        var funcScore = 0;

        $.each(items, function(key, val){
            var type = val['type'];
            var optl = val['optional'] == undefined;

            if ('radio' == type) {
                var length = $('#knee-assessment input[name=' + key + ']:checked').length;
                if (0 == length && !optl) {
                    return;
                }
                $('#knee-assessment input[name=' + key + ']:checked').each(function(k, v){
                    var score = $(this).val();
                    funcScore += getCalculableScore(score);
                });
            } else if('number' == type && calItem122) { // 只有12-2为number
                var degree = $('#knee-assessment input[name=' + key + ']').val();
                funcScore += getDegreeScore(degree, 2); // 力线度数, 力线为1
            }

        });

        $('#knee-assessment input[name="14-1"]').val(funcScore.toFixed(2));
    }

    /**
     * 通用计算方法
     **/
    var generalComputeScore = function(items, node) {
        var funcScore = 0;

        $.each(items, function(key, val){
            var type = val['type'];
            var optl = val['optional'] == undefined;

            if ('radio' == type) {
                $('#knee-assessment input[name=' + key + ']:checked').each(function(k, v){
                    var score = $(this).val();
                    funcScore += getCalculableScore(score);
                });
            } else if('number' == type) {
                var score = $('#knee-assessment input[name=' + key + ']').val();
                funcScore += getCalculableScore(score);
            }

        });

        $(node).val(funcScore);
    }

    /**
     * 填充计算最终结果
     *
     * 临床评分总分 85-100 优, 70-84 良, 60-69 可, <60 差
     */
    var paddingScoreBox = function(){
        var totalItem = ['14-1', '9-1', '3-1'];
        var scoreRange = {'85':'优', '70':'良', '60':'可', '0':'差'};
        var totalScore = 0;

        $.each(totalItem, function(k, v){
            var score = $('#knee-assessment input[name=' + v + ']').val();
            totalScore += getCalculableScore(score);
        });

        $('#15-1').text(getDisplayScore(totalScore));

        var scoreLiteral = scoreRange[0];
        $.each(scoreRange, function(k, v){
            if (totalScore >= getCalculableScore(k)) {
                scoreLiteral = v;
                return v;
            }
        });

        $('#16-1').text(scoreLiteral);
    }
    
     /**
     * 判断字符串是否为blank
     * @param string
     * @return boolean
     */
     var isBlank = function(str){
     	str = str||'';
     	return '' == str.replace(/(^s*)|(s*$)/g, "").trim();
     }

    /**
     * 将字符数字转换成可以计算的数字
     * @param score string
     * @return number
     */
    var getCalculableScore = function(score){
    	score = score || "0";
        score = (typeof score) == undefined  ? "0" : (score == '' ? "0" : score);
        return parseFloat(score);
    }
    
    /**
    * 保留数字小数点后两位, 四舍五入, 避免显示过长数字
    * @param number
    * @return string
    */
    var getDisplayScore = function(number){
    	number = number||0;
    	return number.toFixed(2);
    }

    /**
     * 计算活动度和力线得分 四舍五入
     * 1 活动度 每5度得1分 总分25分 最大125度
     * 2 力线 大于10度时 每增加5度减3分
     * @return number
     */
    var getDegreeScore = function(degree, type){
        var degr = getCalculableScore(degree);
        var score = 0;
        if (type == 1) { // 计算活动度
            score = degr / 5;
        } else { // 计算力线
            score = degr - 10 > 0 ? (degr - 10)/5 * -3 : 0;
        }
        return score;
    }

    /**
     * 计算总分得分与分级
     * 1 计算功能得分 2 计算临床得分 3 计算减分项 4 渲染最终结果
     */
    var computeScore = function(){
    	debugger;
            computeFuncScore();
            clinicalScore();
            checkSpecItem();
            reduceScore();
            paddingScoreBox();
    }
    
    /**
    * 检查力线的填写情况 12-1
    **/
    var checkSpecItem = function(){
    	var checkedLength = $('#knee-assessment input[name="12-1"]:checked').length;
    	if (checkedLength < 1) {
    		return;
    	}
    	
    	var it12 = $('#knee-assessment input[name=12-2]');
    	var checked = $('#knee-assessment input[name=12-1]:checked');
		if(checked.val() == 2) {// 无内外翻
			calItem122 = false;
			it12.val(""); // 将选中的值清空
			// it12.attr("disabled", "disabled");
			it12.attr("readonly", "readonly");
		} else {
			calItem122 = true;
			it12.removeAttr("readonly");
		}
    }
    
    $('#knee-assessment input').change(function(){
        computeScore();
    });

    function getCount() {
        $(".input-score").text(null);
    }

</script>
</html>